/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.utils;

/**
 * Created by Peter.Li on 2015/10/23.
 */
public enum UserStatus {
    ACTIVE(1, "ACTIVE"),
    LOCK(2, "LOCK"),
    DISABLE(3, "DISABLE");

    private int index;
    private String code;

    UserStatus(int index, String code) {
        this.code = code;
        this.index = index;
    }

    public static UserStatus getValueOf(String code) {
        if (ACTIVE.getCode().equals(code)) {
            return ACTIVE;
        } else if (LOCK.getCode().equals(code)) {
            return LOCK;
        } else if (DISABLE.getCode().equals(code)) {
            return DISABLE;
        } else {
            return null;
        }
    }

    public static UserStatus getValueOf(int index) {
        switch (index) {
            case 1:
                return ACTIVE;
            case 2:
                return LOCK;
            case 3:
                return DISABLE;
            default:
                return null;
        }
    }

    public String getCode() {
        return code;
    }

    public int getIndex() {
        return index;
    }
}
